package com.softfly.java;

import java.sql.Connection;
import java.util.concurrent.*;


class WaitThreadRunnable implements Runnable {

    private ConDemo conDemo;

    public WaitThreadRunnable(ConDemo conDemo) {
        this.conDemo = conDemo;
    }

    @Override
    public void run() {
        synchronized (conDemo) {
            try {
                System.out.println("ready to wait");
                conDemo.wait();
                System.out.println("wait over");
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }

}


class NotifyThreadRunnable implements Runnable {

    private ConDemo conDemo;

    public NotifyThreadRunnable(ConDemo conDemo) {
        this.conDemo = conDemo;
    }


    @Override
    public void run() {

    }

}

public class ConDemo {

    public void testTest() {
        synchronized (this) {

        }
    }

    public void testNotify() {
        synchronized (this) {

        }
    }

    public void launch() {
        new Thread(new WaitThreadRunnable(this)).start();
    }

    public static void main(String[] args) throws InterruptedException {
        ConDemo conDemo = new ConDemo();
        conDemo.launch();
        Thread.sleep(3000);
        System.out.println("ready to notify");

        synchronized (conDemo) {
            conDemo.notify();
            Thread.sleep(Integer.MAX_VALUE);
        }

    }
}
